package jlfm.lastfm.apps.recorder;

import jlfm.lastfm.apps.ID3MetadataProvider;
import jlfm.lastfm.tools.id3.ID3Tagger;

public class ID3TaggingListener implements ProgressListener {

	ID3MetadataProvider id3MetadataProvider;

	public ID3TaggingListener(ID3MetadataProvider id3MetadataProvider) {
		this.id3MetadataProvider = id3MetadataProvider;
	}

	public void progressFinished(ProgressEvent e) {
		try {
			ID3Tagger.tag(((FileWritingStreamHandler) e.getSource())
					.getFileNameProvider().getOutputFile(e.getMetadata()),
					id3MetadataProvider.getID3Metadata(e.getMetadata()));
		} catch (RuntimeException exc) {
			exc.printStackTrace();
		}

	}

	public void progressStarted(ProgressEvent e) {
	}

	public void progressUpdated(ProgressEvent e) {
	}

}
